package com.demo.log.aspect;

import com.demo.log.annotation.SysLog;
import com.demo.log.event.SysLogEvent;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

/**
 * 操作日志使用 Spirng event 异步入库
 *
 * @author YT
 * @date 2019-05-23
 */
@Aspect
@Slf4j
public class SysLogAspect {

//    @Around("@annotation(sysLog)")
//    @SneakyThrows
//    public Object around(ProceedingJoinPoint point, SysLog sysLog){
//        String strClassName = point.getTarget().getClass().getName();
//        String strMethodName = point.getSignature().getName();
//        log.debug("[类名]:{},[方法]:{}", strClassName, strMethodName);
//
//        com.demo.log.entity.SysLog logVo = SysLogUtils.getSysLog();
//        logVo.setTitle(sysLog.value());
//        // 发送异步日志事件
//        Long startTime = System.currentTimeMillis();
//        Object obj = point.proceed();
//        Long endTime = System.currentTimeMillis();
//        logVo.setTime(endTime - startTime);
//        SpringContextHolder.publishEvent(new SysLogEvent(logVo));
//        return obj;
//    }
}
